﻿using System.Web.Mvc;
using Tamias.BasicCmsPortableArea.Domain;
using Tamias.BasicCmsPortableArea.Areas.CmsAdmin.ViewModels.ContentItem;

namespace Tamias.BasicCmsPortableArea.Areas.CmsAdmin.Controllers
{
    public class ContentItemController : Controller
    {
        public ContentItemController()
        {
            ContentItemService = new ContentItemService();
        }

        public IContentItemService ContentItemService { get; set; }

        public ActionResult List(int? id)
        {
            var items = ContentItemService.GetList(id.Value);

            var vm = new ListViewModel();
            items.ForEach(item => vm.Items.Add(new ContentItemListViewModel()
            {
                ContentItemId = item.Id,
                Name = item.Name
            }));

            return View(vm);
        }
    }
}
